package MtG.client.panels.dialogs;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.Box;
import javax.swing.ButtonGroup;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTextArea;

/**
 * HelpInfo.java is the class that opens a dialog with some information about this MtG Demo.
 * @author Marek Sirp
 * @author Jaan Sepp
 */
public class HelpInfo extends JDialog{  	
	/**
	 * Determines if a de-serialized file is compatible with this class.
	 */
	private static final long serialVersionUID = 7169890634778527682L;
		Box b = Box.createVerticalBox();
		JTextArea info = new JTextArea(20,1);
	    ButtonGroup group = new ButtonGroup();
		
    	/**
    	 * Constructor
    	 * @param parent parent frame of this frame.
    	 */
    	public HelpInfo(JFrame parent){   		   		
    		super(parent, "Introduction to Magic the Gathering.", true);
            setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
    	    getContentPane().add(b);
    	    info.setText("NOTE: This is the demo version of the real game.\n\n" +
    	    		"In this version you have a choice between 2 premade decks: Fire and Forest.\n" +
    	    		"The game itself requires two players, the number of observers is unlimited.\n" +
    	    		"After you have entered you name and chosen your deck type You can proceed to connecting\n" +
    	    		"to the game server. Then you have to wait until the second player connects and 7 cards \n" +
    	    		"are dealt for each player and the game begins.\n\n" +
    	    		"The first player to move is the one who had to wait for the other player to connect.\n" +
    	    		"Each turn you can draw a card, play one mana card and as many monster cards as you have mana\n" +
    	    		"for. Now you can attack your opponent. If he has defending monsters, your character has to go through\n" +
    	    		"them first. If there are none, you can inflict damage to the player himself. The one to reach 0 hitpoints\n" +
    	    		"first, looses. Each monster can attack once per turn but defend until he dies. At the beginning of next\n" +
    	    		"turn, they get their health back.\n\n" +
    	    		"PS: You can end your turn with the END TURN button.\n" +
    	    		"To place a card on the table, double click it.\n" +
    	    		"To attack, choose your monsters (they get highlighted when you click on them)");
    	    info.setEditable(false);
    	    b.add(info);
    	    JPanel p2 = new JPanel();
    	    JButton close = new JButton("Close");
    	    
            close.addActionListener
            	(new ActionListener() {
            		public void actionPerformed(ActionEvent event) {
            			setVisible(false);
            			dispose();
            			}
            	}
            );
    	    p2.add(close);
    	    b.add(p2);
    	    pack();
    	    setMinimumSize(getSize()); 
    	    setMaximumSize(getSize());
    	    setVisible(true); 
    	}
}
